package com.CGFrame.struts.action.categorySet;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.CGFrame.struts.POJOs.Catemodel;
import com.CGFrame.struts.POJOs.Catemodeltime;
import com.CGFrame.struts.bean.ProjectOperate;
import com.CGFrame.struts.bean.category.CateModelBean;
import com.CGFrame.struts.bean.category.CategoryBean;
import com.CGFrame.struts.bean.category.Catemodelrelbean;
import com.CGFrame.struts.bean.category.CatemodeltimeBean;
import com.CGFrame.struts.bean.log.LogHistoryBean;

public class ModelTimeAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		String time=request.getParameter("modeltime");
		String timeId=request.getParameter("catemodeltimeid");
		String modelId=request.getParameter("catemodelid");
		String regUserId = (String)request.getSession().getAttribute("RegUserID");
		CatemodeltimeBean ctb = new CatemodeltimeBean();
		
		try{
			Integer hours=Integer.valueOf(time);
			ctb.changTime(timeId,hours);
			
			LogHistoryBean logBean = new LogHistoryBean();
			logBean.saveByReguserId(regUserId, LogHistoryBean.MODIFY, "setHours:"+hours, "Catemodeltime", Integer.parseInt(timeId) );
			
		}catch(NumberFormatException e){
			request.setAttribute("notnumber", "input must be number!");
		}
		
		request.setAttribute("modelId", modelId);

		return mapping.findForward("detail");
	}
	
}
